#delimit;
set logtype text;
log using cbs0208.out,
replace; 
set more off;

/* input data from full CBS News data 

use 26143-0001-Data; */

/* read subset of CBS News Data */

insheet using cbs0208.csv, comma names case; 

/* create various party id variables */

gen partyid3=2 if PRTY==1;
replace partyid3=0 if PRTY==2;
replace partyid3=1 if PRTY==3;

gen rep=(PRTY==1) if PRTY<4;
gen dem=(PRTY==2) if PRTY<4;
gen ind=(PRTY==3) if PRTY<4;

/* create overall bush approval */

gen bushappr=(Q1==1) if Q1==1 | Q1==2;

/* create bush policy area approval */

gen busecon=(Q3==1) if Q3==1 | Q3==2;
gen busiraq=(Q4==1) if Q4==1 | Q4==2;

/* Table A.20 in appendix */

logit bushappr busecon busiraq dem rep [pweight=WGHT];

/* rate national economy */

gen econcond=5-Q6 if Q6<9;

/* rate change in national economy */

gen natecon=3 if Q7==1;
replace natecon=2 if Q7==3;
replace natecon=1 if Q7==2;

/* rate progress of war in Iraq */

gen iraqprog=5-Q77 if Q77<9;

/* show factors influencing overall approval (Table A.20 in appendix) */

logit bushappr econcond iraqprog dem rep [pweight=WGHT];
logit bushappr natecon iraqprog dem rep [pweight=WGHT];

/* create subset of CBS News poll data */

/* outsheet WGHT PRTY Q1 Q3 Q4 Q6 Q7 Q77 using cbs0208.csv, comma
nolabel replace; */

log close;

